﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.OleDb;

namespace WebSite_CodeMan
{
    public partial class Search : System.Web.UI.Page
    {
        protected string[] WebMes = new string[6];
        protected string strRightNote = string.Empty;
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                LoadSearch();
            }
        }
        private void GetBaseMes()
        {
            string strKeys = Common.GetMes.GetRequestQuery(Request, "keys");
            OleDbDataReader DataRead = BLL.WebInfo.GetWebBaseInfo("5");
            if (DataRead.HasRows)
            {
                DataRead.Read();
                WebMes[0] = DataRead["T_WebName"].ToString();
                WebMes[1] = DataRead["T_WebKey"].ToString();
                WebMes[2] = DataRead["T_WebDes"].ToString();
                WebMes[3] = DataRead["T_WebWord"].ToString();
                WebMes[4] = DataRead["T_WebLink"].ToString() + "&nbsp;<img src=\"../Images/IBCMes.gif\"/>&nbsp;" + DataRead["T_WebNumber"].ToString() + "&nbsp;" + DataRead["T_SPSSMes"].ToString();
                WebMes[5] = BaseClass.HtmlCommon.GetWebMenu("").ToString();
            }
            DataRead.Close();
            DataRead.Dispose();

            strRightNote = BaseClass.HtmlCommon.HtmlSearch()+BaseClass.HtmlCommon.HtmlGetClassMes().ToString() + BaseClass.HtmlCommon.HtmlGetHotKey("20", Page) + BaseClass.HtmlCommon.HtmlGetTopNote();
        }
        private void LoadSearch()
        {
            GetBaseMes();
            string strKeys = Common.GetMes.GetRequestQuery(Request, "keys");
            if (!string.IsNullOrEmpty(strKeys))
            {
            int PageCount = 0;
            int RecordCount = 0;
            string strWhere = string.Format(" WHERE T_NoteTitle like {0} or T_NoteKey like {0} or T_NoteDes like {0} ", "'%" + strKeys + "%'");
            RpData.DataSource = BLL.NoteInfo.GetAllNoteInfo(PagerSearch.CurrentPageIndex, PagerSearch.PageSize, out PageCount, out RecordCount, strWhere);
            RpData.DataBind();
            PagerSearch.RecordCount = RecordCount;
                
            }
        }

        protected void PagerSearch_PageChanged(object sender, EventArgs e)
        {
            LoadSearch();
        }
    }
}
